#include "xthread.h"
#include "stdio.h"
#include "stdlib.h"
#include "unistd.h"

struct xthread* thread_start(void* (*run)(void *arg),void *args){

	pthread_attr_t attr;
      	pthread_attr_init(&attr);
      	pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED);

	pthread_t tid;
      	pthread_create(&tid,&attr,run,args);

	pthread_attr_destroy(&attr);
	
	size_t size= sizeof(struct xthread);
	struct xthread *pthd=(struct xthread*)malloc(size);
	pthd->thrd=tid;
	pthd->args=args;
	return pthd;
}

int thread_stop(struct xthread* thread){return 0;}

void* func(void *param){
	int i=0;
	for(;i<100;++i){printf("abc %d\n",i);}
	
	return NULL;
}

